﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:data="clr-namespace:Tomers.WPF.DataVirtualization.Data"
             x:Name="userControl" x:Class="SqlExport.View.DataViewDataGrid"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             DataContext="{Binding DataViewViewModel, Source={StaticResource Locator}}">
	<UserControl.Resources>
		<ResourceDictionary>
			<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
				<Setter Property="Padding" Value="2"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type DataGridCell}">
							<Border Padding="{TemplateBinding Padding}" 
                                    BorderBrush="{TemplateBinding BorderBrush}" 
                                    BorderThickness="{TemplateBinding BorderThickness}" 
                                    Background="{TemplateBinding Background}" 
                                    SnapsToDevicePixels="True">
								<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
							</Border>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
		</ResourceDictionary>
	</UserControl.Resources>

	<Grid>
		<Grid.Resources>
			<CollectionViewSource x:Key="ListViewViewSource"
                          CollectionViewType="{x:Type data:DataVirtualizationCollectionView}"
                          Source="{Binding ItemsSource}" />
		</Grid.Resources>
		<DataGrid x:Name="grid" ItemsSource="{Binding Source={StaticResource ListViewViewSource}}" 
				  VirtualizingStackPanel.IsVirtualizing="True"
				  VirtualizingStackPanel.VirtualizationMode="Recycling"
                  IsReadOnly="True"
                  CanUserReorderColumns="False"
                  AlternatingRowBackground="WhiteSmoke"
                  HorizontalGridLinesBrush="LightGray"
                  VerticalGridLinesBrush="LightGray"
				  AutoGenerateColumns="False"
                  CellStyle="{StaticResource DataGridCellStyle}">
		</DataGrid>
	</Grid>
</UserControl>
